<?php
/**
 * Sets that the projecte is viewed.
 */

// Start the session handling system
session_start ();

// Connect to the database
require_once ("../../../db.php");

// Only allow this for employee users
if (!isset($_SESSION['uid']) || ($_SESSION['type'] != 'employee'))
    die('Not logged in as an employee user');

// insert viewed so the employee knows that he have already viewed that project
$sql = 'INSERT INTO staffcomments
        VALUES ("'.$_SESSION["uid"].'", '.$_POST["pid"].',"",1)
            ON DUPLICATE KEY UPDATE uid=uid';
        
$sth = $db->prepare($sql);
$sth->execute();
$row = $sth->fetchAll();

if ($row) echo json_encode($row);

else      echo json_encode(array('error' =>
            'Something went wrong with projectviewed in the database.'));

?>